import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    islogin: sessionStorage.getItem('islogin'),
    name: sessionStorage.getItem('name'),
    shopCart: JSON.parse(sessionStorage.getItem('shopCart')) || []
  },
  mutations: {
    loginOK(state, value) {
      state.islogin = value;
      state.name = value;
    },
    addShopCar(state, obj) {
      state.shopCart.push(obj)
    },
    delShopCar(state, arr) {
      state.shopCart = arr
    }
  },
  actions: {},
  modules: {}
})